package model.Entity.SIS;

import java.io.Serializable;
import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;


/**
 * The persistent class for the SIS_COURSE_ACTIVITIES database table.
 * 
 */
@Entity
@Table(name="SIS_COURSE_ACTIVITIES")
@NamedQueries({
    @NamedQuery(name = "CourseActivity.findAll", query = "SELECT s FROM CourseActivity s"),
    @NamedQuery(name = "CourseActivity.findByCourseNo", query = "SELECT s FROM CourseActivity s WHERE s.courseActivityPK.courseNo = :courseNo"),
    @NamedQuery(name = "CourseActivity.findByCourseEdition", query = "SELECT s FROM CourseActivity s WHERE s.courseActivityPK.courseEdition = :courseEdition"),
    @NamedQuery(name = "CourseActivity.findByActivityCode", query = "SELECT s FROM CourseActivity s WHERE s.courseActivityPK.activityCode = :activityCode"),
    @NamedQuery(name = "CourseActivity.findByContactHrs", query = "SELECT s FROM CourseActivity s WHERE s.contactHrs = :contactHrs"),
    @NamedQuery(name = "CourseActivity.findByIsMain", query = "SELECT s FROM CourseActivity s WHERE s.isMain = :isMain"),
    @NamedQuery(name = "CourseActivity.findByEntryDate", query = "SELECT s FROM CourseActivity s WHERE s.entryDate = :entryDate"),
    @NamedQuery(name = "CourseActivity.findByTerminal", query = "SELECT s FROM CourseActivity s WHERE s.terminal = :terminal"),
    @NamedQuery(name = "CourseActivity.findByOsUser", query = "SELECT s FROM CourseActivity s WHERE s.osUser = :osUser")})

public class CourseActivity implements Serializable {
	private static final long serialVersionUID = 1L;

	@EmbeddedId
	private CourseActivityPK courseActivityPK;

	@Column(name="CONTACT_HRS")
	private BigDecimal contactHrs;

	@Temporal(TemporalType.DATE)
	@Column(name="ENTRY_DATE")
	private Date entryDate;

	@Column(name="ENTRY_USER")
	private BigDecimal entryUser;

	@Column(name="IS_MAIN")
	private BigDecimal isMain;

	@Column(name="OS_USER")
	private String osUser;

	private String terminal;

	//bi-directional many-to-one association to SisActivity
	@ManyToOne
	@JoinColumn(name="ACTIVITY_CODE", insertable=false, updatable=false)
	private Activity activity;

	//bi-directional many-to-one association to SisTimetable
	@OneToMany(mappedBy="courseActivity")
	private List<Timetable> timetables;

	public CourseActivity() {
	}

	public CourseActivityPK getCourseActivityPK() {
		return this.courseActivityPK;
	}

	public void setCourseActivityPK(CourseActivityPK id) {
		this.courseActivityPK = id;
	}

	public BigDecimal getContactHrs() {
		return this.contactHrs;
	}

	public void setContactHrs(BigDecimal contactHrs) {
		this.contactHrs = contactHrs;
	}

	public Date getEntryDate() {
		return this.entryDate;
	}

	public void setEntryDate(Date entryDate) {
		this.entryDate = entryDate;
	}

	public BigDecimal getEntryUser() {
		return this.entryUser;
	}

	public void setEntryUser(BigDecimal entryUser) {
		this.entryUser = entryUser;
	}

	public BigDecimal getIsMain() {
		return this.isMain;
	}

	public void setIsMain(BigDecimal isMain) {
		this.isMain = isMain;
	}

	public String getOsUser() {
		return this.osUser;
	}

	public void setOsUser(String osUser) {
		this.osUser = osUser;
	}

	public String getTerminal() {
		return this.terminal;
	}

	public void setTerminal(String terminal) {
		this.terminal = terminal;
	}

	public Activity getSisActivity() {
		return this.activity;
	}

	public void setSisActivity(Activity activity) {
		this.activity = activity;
	}

	public List<Timetable> getSisTimetables() {
		return this.timetables;
	}

	public void setSisTimetables(List<Timetable> timetables) {
		this.timetables = timetables;
	}

	public Timetable addSisTimetable(Timetable timetable) {
		getSisTimetables().add(timetable);
		timetable.setCourseActivity(this);

		return timetable;
	}

	public Timetable removeSisTimetable(Timetable timetable) {
		getSisTimetables().remove(timetable);
		timetable.setCourseActivity(null);

		return timetable;
	}
	
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (courseActivityPK != null ? courseActivityPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CourseActivity)) {
            return false;
        }
        CourseActivity other = (CourseActivity) object;
        if ((this.courseActivityPK == null && other.courseActivityPK != null) || (this.courseActivityPK != null && !this.courseActivityPK.equals(other.courseActivityPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.SisCourseActivities[ sisCourseActivitiesPK=" + courseActivityPK + " ]";
    }

}